/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.games.base;

import org.ceroproject.games.Action;
import org.ceroproject.games.ActionRule;
import org.ceroproject.games.Card;
import org.ceroproject.games.Game;
import org.ceroproject.games.InitializationException;
import org.ceroproject.games.ValidationException;
import org.ceroproject.games.Zone;

public class RuleLookAtYourCards implements ActionRule {

	public boolean allowsAction(Action action) {
		boolean found;
		for (Card card : action.getEvent().getCards()) {
			found = false;
			for (Zone zone : action.getEvent().getPlayer().getZones()) {
				if (zone.getSortedList().contains(card)) {
					found = true;
					break;
				}
			}
			if (!found)
				return false;
		}
		return true;
	}

	public boolean forbidsAction(Action action) {
		return false;
	}

	public String getRuleName() {
		return "Look at your cards";
	}

	public String getRuleDescription() {
		return "Allows players to look at their cards";
	}

	public String getRuleConstraints() {
		return null;
	}

	public void validateGame(Game game) throws ValidationException {
	}

	public Class ruledAction() {
		return ActionLookAtCards.class;
	}

	public void initializeRule(Game game) throws InitializationException {
	}

}
